CREATE OR REPLACE PACKAGE "kesplus_platform"."idcard_util" AUTHID CURRENT_USER AS
    /**
     * 提取前6位行政区划码
     */
    function adcode(id text) returns integer;
    /**
     * 提取出生日期
     */
    function birthday(id text) returns date;
    /**
     * 提取尾部后三位
     */
    function id_sequence(id text) returns varchar(3);
    /**
     * 是否为男性
     */
    function is_male(id text) return boolean;
    /**
     * 是否为女性
     */
    function is_female(id text) return boolean;
    /**
     * 计算校验和
     */
    function calculate_checksum(id text) return varchar(1);
    /**
     * 校验是否为一代身份证
     */
    function valid_v1(id text) returns boolean;
    /**
     * 校验是否为二代身份证
     */
    function valid_v2(id text) returns boolean;
    /**
     * 创建一个二代身份证
     */
    function new_v2(adcode integer, birthday date, seq integer) return varchar(18);
    /**
     * 创建随机身份证
     */
    function random_code() returns varchar(18);
end;

CREATE OR REPLACE PACKAGE BODY "kesplus_platform"."idcard_util" AS WRAPPED
JRg2h7P8/vjdlgRpsm7+XpsXQ8tTyxdYF1cVUMrI5BTPGtIAysYIlRasO6NY
SDVzG5SMU1x7cVNm0ZJhkpZj2vYIdh7Ap7rYWHJwS8YBl02AnuXibDV1G2Xf
Ue8u1GRhETPw6Dfok9ss/FArD6GJ5dM2hQTI0Y50/QoGOM2GG3gHworgORq2
eiDhMvX9gy1Of130S08bIbOGphQUdSbU69ueS4ueDTaHC+fg4J9ytqwrpDrJ
CcFVEwLknibHiGVEDJn3EMb+8o/vYjxK6GMkJEmRjBiTttw6D8KnYp5vCSRr
Wfj5JqZ0vImcKruIXd8ZYQdqqO+Z6tl//SY9SE8z0/ncEDAjnU0Kn9kOpMtU
V3oN4z1GKpiJ3I97L8B0KJ1dmppUhg5oxOU1uoZibFFgBPb1RBQ8WNxNr63p
GWAzJ+MN197LeisMhmoSFTyHmHLsblakIHLjF6N8TUhqOTyzo67RpDlptgjH
SsbAmJnxLEnV4mgLuD6Bt0smt1Cy3zAM4x6ea8burVL78j2ziR+jvgButkFe
ZKfK+xRJB4Yc7Z8x8Cm+Sr+aT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